package com.springboot.service.aop;

import com.springboot.service.condition.TaskFilterCondition;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Conditional;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @Author: luobendexiaoqiang
 * @Date: 2020/7/24 19:48
 */
@Slf4j
@Component()
@Aspect
//@Order(3)
@Conditional(TaskFilterCondition.class)
public class FilterScheduledAop {


    /* 拦截@Scheduled注解 */
    @Pointcut(" @annotation(org.springframework.scheduling.annotation.Scheduled)")
    public void proxyAspect() {

    }

    /**
     * 拦截不到private方法
     *
     * @param joinPoint
     * @return
     */
    @Around("proxyAspect()")
    public Object doInvoke(ProceedingJoinPoint joinPoint) {

        log.info("定时任务开始被拦截order3");
        try {
            joinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        log.info("定时任务结束被拦截order3");
        return null;
    }
}